package com.iflytek.iot.common.exception;


import com.iflytek.iot.common.constants.BaseErrorCode;
import com.iflytek.iot.common.constants.IMessage;

/**
 * 项目中所有异常均继承此异常,不要自定义检查异常
 *
 * @author zurun
 * @date 2018/6/15 16:17:05
 */
public class IflytekRuntimeException extends RuntimeException {
    /**
     * 异常码/错误码
     */
    private String errCode;

    protected IflytekRuntimeException(String errCode, String errMsg) {
        super(errMsg);
        this.errCode = errCode;
    }

    protected IflytekRuntimeException(String errMsg) {
        super(errMsg);
        errCode = BaseErrorCode.common.UNKNOWN_ERROR.getErrCode();
    }

    protected IflytekRuntimeException(IMessage errCode) {
        super(errCode.getErrMsg());
        this.errCode = errCode.getErrCode();
    }

    protected IflytekRuntimeException(IMessage errCode, String errMsg) {
        super(errMsg);
        this.errCode = errCode.getErrCode();
    }


    public String getErrCode() {
        return errCode;
    }

    @Override
    public String getMessage() {
        return super.getMessage();
    }
}
